<template>
	<scroll-view class="sale-scroll" scroll-x :style="{'--price':vuex_config.price}" v-if="dataList && dataList[0]">
		<view class="flash-salse-item" v-for="(item, index) in dataList" :key="index" @click="goDetail(item)">
			<view class="flash-salse-item-top">
				<view class="item-top-img">
					<image class="img" :src="item.logo"></image>
				</view>
				<view class="item-top-time">
					<time-diff color="#fff" :sale_time="item.sale_time" :small="true" :start="item.start_date" :end="item.end_date"></time-diff>
				</view>
			</view>
			<view class="flash_bottom">
				<view class="u-line-1">{{item.name}}</view>
				<view class="bottom-price">
					<text class="item_bottom_sign">￥</text>
					<text class="item_bottom_price">{{ item.price }}</text>
					<text class="item-bottom-right" v-if="item.market_price > 0">￥{{item.market_price}}</text>
				</view>
			</view>
		</view>
	</scroll-view>
</template>

<script>
	import {
		configMixin
	} from './configMixin.js';
	import timeDiff from '@/pagecomponents/FlashSale/timeDiffNew.vue';
	export default {
		mixins: [configMixin],
		components: {
			timeDiff
		},
		data() {
			return {};
		},
		methods: {
			goDetail(item) {
				let currentTime = new Date().getTime();
				if (item.type == 2 && currentTime > item.end_date) {
					this.$toast({
						title: '活动已结束'
					})
					return
				}
				this.$toProd({
					...item,
					prodType: 1
				})
			},
		}
	};
</script>

<style lang="scss" scoped>
	.sale-scroll {
		white-space: nowrap;
		overflow: hidden;
		padding: 10rpx 24rpx;
		box-sizing: border-box;
		background-color: #fff;
	}

	.flash-salse-item {
		width: 220rpx;
		background-color: #fff;
		display: inline-block;
		margin-right: 30rpx;

		&:last-child {
			margin-right: 0;
		}
	}

	.flash-salse-item-top {
		position: relative;
		border-radius: 8rpx;
		overflow: hidden;

		.item-top-img {
			width: 100%;
			padding-bottom: 100%;
			position: relative;
			.img {
				position: absolute;
				top: 0;
				left: 0;
				width: 100%;
				height: 100%;
			}
		}

		.item-top-time {
			width: 100%;
			display: flex;
			justify-content: center;
			align-items: center;
			height: 48rpx;
			background: rgba(0, 0, 0, 0.4);
			position: absolute;
			bottom: 0;
			left: 0;
		}
	}

	.flash_bottom {
		padding: 16rpx 0 0;

		.bottom-price {
			margin-top: 10rpx;
			color: var(--price);
		}
	}

	.item_bottom_sign {
		font-size: 24rpx;
	}

	.item_bottom_price {
		font-size: 38rpx;
		margin-right: 8rpx;
	}

	.item-bottom-right {
		color: #808080;
		font-size: 24rpx;
		text-decoration: line-through;
	}
</style>
